#ifndef MAIN_INTERFACE_H
#define MAIN_INTERFACE_H

#include <QMainWindow>

#include <QThread>

#include <QTextToSpeech>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainInterface;
}
QT_END_NAMESPACE

#include<QLabel>
class MyQLabel : public QLabel{
    Q_OBJECT
    // Q_PROPERTY(QPointF pos READ pos WRITE setPos)  //移动
    Q_PROPERTY(int rotation READ rotation WRITE setRotation) //旋转

public:
    int m_Rot;
    void setRotation(qreal angle){
        m_Rot = angle;
        update();
    }
    qreal rotation() const { return m_Rot; }
};

class MainInterface : public QMainWindow
{
    Q_OBJECT
public:
    MainInterface(QWidget *parent = nullptr);
    ~MainInterface();

private:
    /**
     * @brief 初始化界面
     */
    void initializeInterface();
    /**
     * @brief 初始化界面功能
     */
    void initializeFunction();

    QImage rotateImage(const QImage &image, qreal fAngle);

private:
    Ui::MainInterface *ui;

    //记录之前的大小闸位置
    int m_bigGateTypeEver;
    int m_smallGateTypeEver;

    QTimer *timer = nullptr;

    //计算下位机数据的线程
    QThread m_calculateLowerComputerDataThread;

  //  CalculateLowerComputerData* m_calculateLowerComputerData;

    //语音播报
    QTextToSpeech* m_speech;

protected:
    /**
     * @brief 键盘按压事件
     * @param event
     */
    void keyPressEvent(QKeyEvent *event);
    /**
     * @brief 键盘松开事件
     * @param event
     */
    void keyReleaseEvent(QKeyEvent *event);

signals:

    void startCalculateLowerComputerData();

    void stopCalculateLowerComputerData();

    //发送总风缸(黑)和制动缸压力（红）
    void sendTotalWindCylinderPressureAndbrakeCylinderPressureData(short totalWindCylinderPressure, short brakeCylinderPressureData);
    //发送列车管（黑）和均风缸压力（红）
    void sendTrainPipePressureDataAndEqualizeCylinderPressure(short totalWindCylinderPressure, short brakeCylinderPressureData);

    //发送大闸角度值
    void sendBigGateValueChanage(int);

    void sendSmallGateValueChanage(int);

    //大闸位下压
    void sendBigGatePressDown(bool);

    void sendSmallGatePressDown(bool);
};
#endif // MAIN_INTERFACE_H
